package domain

import (
	"time"
)

const (
	ClubPositionFieldClubID = "club_id"
)

type ClubPosition struct {
	ID            int64     `json:"id"`
	ClubID        *int64    `json:"-"`
	ParentID      *int64    `json:"-"`
	FaviconID     *int64    `json:"-"`
	Name          string    `json:"name" gorm:"type:varchar(255);not null;"`
	Description   *string   `json:"description"`
	IsDefaultJoin bool      `json:"is_default_join" gorm:"not null;default:false"`
	CreatedAt     time.Time `json:"created_at" `
	UpdatedAt     time.Time `json:"updated_at" `

	CoverImages []*Assets     `json:"cover_images" gorm:"many2many:club_position_cover_images"`
	Favicon     *Assets       `json:"favicon" gorm:"foreignKey:FaviconID"`
	Club        *Club         `json:"club" gorm:"foreignKey:ClubID"`
	Parent      *ClubPosition `json:"parent" gorm:"foreignKey:ParentID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
}

type ClubPositionDTO struct {
	ID            int64     `json:"id"`
	ClubID        *int64    `json:"-"`
	ParentID      *int64    `json:"-"`
	FaviconID     *int64    `json:"-"`
	Name          string    `json:"name" gorm:"type:varchar(255);not null;"`
	Description   *string   `json:"description"`
	IsDefaultJoin bool      `json:"is_default_join" gorm:"not null;default:false"`
	CreatedAt     time.Time `json:"created_at" `
	UpdatedAt     time.Time `json:"updated_at" `

	CoverImages []*AssetsDTO     `json:"cover_images" gorm:"many2many:club_position_cover_images"`
	Favicon     *AssetsDTO       `json:"favicon" gorm:"foreignKey:FaviconID"`
	Club        *ClubDTO         `json:"club" gorm:"foreignKey:ClubID"`
	Parent      *ClubPositionDTO `json:"parent" gorm:"foreignKey:ParentID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
}
